package com.atguigu.lease.common.sms;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/***
 * 阿里云短信服务配置类
 * 可以借鉴minio的配置类写法
 */
@Configuration
@EnableConfigurationProperties(SmsProperties.class)
public class AliyunSmsConfiguration {
    @Autowired
    private SmsProperties smsProperties;
    @Bean
    public Client Client() throws Exception {
        //借鉴minio的配置类写法   一模一样的写法
        Config config = new Config();
        config.setAccessKeyId(smsProperties.getAccessKeyId());
        config.setAccessKeySecret(smsProperties.getAccessKeySecret());
        config.setEndpoint(smsProperties.getEndPoint());
        return new Client(config);
    }
}
